home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / tcl / xf2.3-p / xf2 / xf2.3 / additionals / Bargraph < prev    next >
Encoding:
Text File  |  1993-11-20  |  7.4 KB  |  219 lines

  1. # Program: xf
  2. # Description: handle bargraph widgets
  3. #
  4. # $Header: Bargraph[2.3] Wed Mar 10 11:57:18 1993 garfield@garfield frozen $
  5.  
  6. global xfDefaultConf
  7. set xfDefaultConf(bargraph) 4
  8.  
  9. ##########
  10. # Procedure: XFAdd.Bargraph
  11. # Description: add a bargraph
  12. # Arguments: xfW - the widget
  13. #            xfName - a optional name
  14. #            xfType - add or config
  15. # Returns: none
  16. # Sideeffects: none
  17. ##########
  18. proc XFAdd.Bargraph {xfW xfName xfType} {
  19.   global xfStatus
  20.  
  21.   XFEditSetStatus "Inserting Bargraph..."
  22.   set xfName [XFMiscGetUniqueName $xfName bargraph]
  23.   if {"$xfStatus(path)" == "."} {
  24.     if {"$xfType" == "add"} {
  25.       if {[catch "bargraph .$xfName" xfResult]} {
  26.         XFProcError "$xfResult"
  27.         XFEditSetStatus "Inserting Bargraph...aborted"
  28.         return
  29.       }
  30.     } {
  31.       if {[catch "bargraph .$xfName" xfResult]} {
  32.         XFProcError "$xfResult"
  33.         XFEditSetStatus "Inserting Bargraph...aborted"
  34.         return
  35.       }
  36.     }
  37.  
  38.     XFMiscPositionWidget .$xfName
  39.     XFMiscBindWidgetTree .$xfName
  40.   } {
  41.     if {"$xfType" == "add"} {
  42.       if {[catch "bargraph $xfStatus(path).$xfName" xfResult]} {
  43.         XFProcError "$xfResult"
  44.         XFEditSetStatus "Inserting Bargraph...aborted"
  45.         return
  46.       }
  47.     } {
  48.       if {[catch "bargraph $xfStatus(path).$xfName" xfResult]} {
  49.         XFProcError "$xfResult"
  50.         XFEditSetStatus "Inserting Bargraph...aborted"
  51.         return
  52.       }
  53.     }
  54.  
  55.     XFMiscPositionWidget $xfStatus(path).$xfName
  56.     XFMiscBindWidgetTree $xfStatus(path).$xfName
  57.   }
  58.  
  59.   incr xfStatus(elementCounter)
  60.   XFEditSetPath $xfStatus(path)
  61.   XFEditSetStatus "Inserting Bargraph...done"
  62. }
  63.  
  64. ##########
  65. # Procedure: XFConfig.Bargraph4
  66. # Description: configure a bargraph
  67. # Arguments: xfW - the widget
  68. #            xfType - config type (add or config)
  69. #            xfClass - the class we configure
  70. #            xfLeader - the leading window
  71. # Returns: none
  72. # Sideeffects: none
  73. ##########
  74. proc XFConfig.Bargraph4 {xfW xfType xfClass {xfLeader ""}} {
  75.   global xfStatus
  76.  
  77.   if {"$xfType" == "add"} {
  78.     set xfName bargraph$xfStatus(elementCounter)
  79.   } {
  80.     set xfName [XFMiscPathName $xfW]
  81.   }
  82.   XFEditSetStatus "Calling parameter setting for Bargraph..."
  83.  
  84.   # build widget structure
  85.   XFTmpltToplevel .xf${xfClass}Config4 400x600 \
  86.     "Bargraph parameters:[XFMiscPathTail $xfW]" $xfLeader
  87.  
  88.   XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass \
  89.     XFBargraphSetBargraph4 parameters $xfName 4
  90.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
  91.     background Background "Background" XFBargraphSetBargraph4
  92.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass barcolor \
  93.     barcolor Barcolor "Bar color" XFBargraphSetBargraph4
  94.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass base \
  95.     base Base "Base" "" 1000 \
  96.       XFBargraphSetBargraph4
  97.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass interval \
  98.     interval Interval "Interval" XFBargraphSetBargraph4
  99.   XFElementOrient $xfW .xf${xfClass}Config4 $xfType $xfClass \
  100.     XFBargraphSetBargraph4
  101.   XFElementSize $xfW .xf${xfClass}Config4 $xfType $xfClass \
  102.     XFBargraphSetBargraph4
  103.   XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass title \
  104.     title Title "Text" XFBargraphSetBargraph4
  105.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass textcolor \
  106.     textcolor Foreground "Text color" XFBargraphSetBargraph4
  107.   XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass tickcolor \
  108.     tickcolor Foreground "Tick color" XFBargraphSetBargraph4
  109.   XFElementScale $xfW .xf${xfClass}Config4 $xfType $xfClass tickinterval \
  110.     tickinterval Tickinterval "Tickinterval" "pixels" 100 \
  111.       XFBargraphSetBargraph4
  112.   XFElementScaleDouble $xfW .xf${xfClass}Config4 $xfType \
  113.     $xfClass value "Value" "Min" "Max" 1000 1000
  114.   XFElementCommand $xfW .xf${xfClass}Config4 $xfType
  115.   
  116.   .xf${xfClass}Config4.params1.params2.value.value1.value1 set \
  117.     [lindex [$xfW config -min] 4]
  118.   .xf${xfClass}Config4.params1.params2.value.value2.value2 set \
  119.     [lindex [$xfW config -max] 4]
  120.  
  121.   XFMiscSetResource \
  122.     .xf${xfClass}Config4.params1.params2.value.value1.value1 \
  123.       command "XFBargraphSetBargraph4 $xfW 0 $xfClass"
  124.   XFMiscSetResource \
  125.     .xf${xfClass}Config4.params1.params2.value.value2.value2 \
  126.       command "XFBargraphSetBargraph4 $xfW 0 $xfClass"
  127.  
  128.   # save current parameter
  129.   XFElementSave $xfW $xfClass {background barcolor base interval orient title textcolor tickcolor tickinterval max min width height command}
  130.  
  131.   # packing
  132.   pack append .xf${xfClass}Config4.params1 \
  133.               .xf${xfClass}Config4.params1.params2 {left fill expand}
  134.   pack append .xf${xfClass}Config4 \
  135.               .xf${xfClass}Config4.pathname {top fill frame center} \
  136.               .xf${xfClass}Config4.leave {bottom fill} \
  137.               .xf${xfClass}Config4.additional {bottom fill} \
  138.               .xf${xfClass}Config4.params1 {top fill expand}
  139.  
  140.   XFBindFormConnect .xf${xfClass}Config4.params1.params2 \
  141.     "XFBargraphSetBargraph4 $xfW 0 $xfClass"
  142.  
  143.   XFEditSetStatus "Calling parameter setting for Bargraph...done"
  144. }
  145.  
  146. ##########
  147. # Procedure: XFSaveSpecial.Bargraph
  148. # Description: save bargraph
  149. # Arguments: xfW - the widget
  150. # Returns: none
  151. # Sideeffects: none
  152. ##########
  153. proc XFSaveSpecial.Bargraph {xfW} {
  154.  
  155.   return "\n  $xfW set [$xfW get]"
  156. }
  157.  
  158. ##########
  159. # Procedure: XFBargraphSetBargraph4
  160. # Description: set bargraph parameters
  161. # Arguments: xfW - the widget
  162. #            xfType - the type of setting (1 = set always, 0 = set
  163. #                     only if permanent apply is on)
  164. #            xfClass - the class we configure
  165. #            xfParam1 - ignored parameter
  166. # Returns: none
  167. # Sideeffects: none
  168. ##########
  169. proc XFBargraphSetBargraph4 {xfW xfType xfClass {xfParam1 ""}} {
  170.   global xfConf
  171.   global xfMisc
  172.  
  173.   if {$xfType == 0 && !$xfConf(applyParameters)} {
  174.     return
  175.   }
  176.   if {"[info commands $xfW]" == ""} {
  177.     return
  178.   }
  179.   XFMiscSetSymbolicName $xfW \
  180.     [.xf${xfClass}Config4.params1.params2.symname.symname get]
  181.  
  182.   XFMiscSetResource $xfW background \
  183.     [.xf${xfClass}Config4.params1.params2.bg.bg get]
  184.   if {"[.xf${xfClass}Config4.params1.params2.barcolor.barcolor get]" != ""} {
  185.     XFMiscSetResource $xfW barcolor \
  186.       [.xf${xfClass}Config4.params1.params2.barcolor.barcolor get]
  187.   }
  188.   XFMiscSetResource $xfW base \
  189.     [.xf${xfClass}Config4.params1.params2.base.base get]
  190.   XFMiscSetResource $xfW command \
  191.     [XFMiscGetText .xf${xfClass}Config4.params1.params2.command.command.command]
  192.   if {"[.xf${xfClass}Config4.params1.params2.interval.interval get]" != ""} {
  193.     XFMiscSetResource $xfW interval \
  194.       [.xf${xfClass}Config4.params1.params2.interval.interval get]
  195.   } {
  196.     XFMiscSetResource $xfW interval 0
  197.   }
  198.   XFMiscSetResource $xfW max \
  199.     [.xf${xfClass}Config4.params1.params2.value.value2.value2 get]
  200.   XFMiscSetResource $xfW min \
  201.     [.xf${xfClass}Config4.params1.params2.value.value1.value1 get]
  202.   XFMiscSetResource $xfW orient $xfMisc(orient)
  203.   XFMiscSetResource $xfW textcolor \
  204.     [.xf${xfClass}Config4.params1.params2.textcolor.textcolor get]
  205.   XFMiscSetResource $xfW tickcolor \
  206.     [.xf${xfClass}Config4.params1.params2.tickcolor.tickcolor get]
  207.   XFMiscSetResource $xfW tickinterval \
  208.     [.xf${xfClass}Config4.params1.params2.tickinterval.tickinterval get]
  209.   XFMiscSetResource $xfW title \
  210.     [.xf${xfClass}Config4.params1.params2.title.title get]
  211.   XFMiscSetResource $xfW height \
  212.     [.xf${xfClass}Config4.params1.params2.size.size2.size2 get]
  213.   XFMiscSetResource $xfW width \
  214.     [.xf${xfClass}Config4.params1.params2.size.size1.size1 get]
  215. }
  216.  
  217. # eof
  218.  
  219.